#ifndef BM_CAMERA_H
#define BM_CAMERA_H

/***********************************************************************************************************/
/* Team Black Voltage takes no credit for this file - credits: http://www.codecolony.de/opengl.htm#camera2 */
/***********************************************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
#include <vector>
#include "SDL/SDL.h"

#define PI 3.1415265359
#define PIdiv180 3.1415265359/180.0


/////////////////////////////////
//Note: All angles in degrees  //
/////////////////////////////////

struct SF3dVector  //Float 3d-vect, normally used
{
	GLfloat x,y,z;
};
struct SF2dVector
{
	GLfloat x,y;
};

class BMCamera
{
private:
	SF3dVector Position;
	SF3dVector ViewDir;		/*Not used for rendering the camera, but for "moveforwards"
							So it is not necessary to "actualize" it always. It is only
							actualized when ViewDirChanged is true and moveforwards is called*/
	bool ViewDirChanged;
	GLfloat RotatedX, RotatedY, RotatedZ;
	float lastx, lasty;
	float movedY;
	void GetViewDir ( void );
	int mouse_move;
public:
	BMCamera();				//inits the values (Position: (0|0|0) Target: (0|0|-1) )
	void Render ( void );	//executes some glRotates and a glTranslate command
							//Note: You should call glLoadIdentity before using Render
	void MoveTo(SF3dVector Direction);
	void Move ( SF3dVector Direction );
	void RotateX ( GLfloat Angle );
	void RotateY ( GLfloat Angle );
	void RotateZ ( GLfloat Angle );
	void RotateXYZ ( SF3dVector Angles );
	void setAngleX(float sx);
	void setAngleY(float sy);
	void setAngleZ(float sz);
	void setX(float sx);
	void setY(float sy);
	void setZ(float sz);
	GLfloat getX();
	GLfloat getY();
	GLfloat getMovedY();
	GLfloat getZ();
	GLfloat getAngleX();
	GLfloat getAngleY();
	GLfloat getAngleZ();
	void MoveForwards ( GLfloat Distance );
	void StrafeRight ( GLfloat Distance );
	void setPosition(SF3dVector vector);
	void mouseMove(float x, float y, int windowWidth, int windowHeight, int use_joystick, float sensitivity);
	void reset();
};


SF3dVector F3dVector ( GLfloat x, GLfloat y, GLfloat z );
SF3dVector AddF3dVectors ( SF3dVector * u, SF3dVector * v);
void AddF3dVectorToVector ( SF3dVector * Dst, SF3dVector * V2);

#endif
